#@layout()

#define content()

<div class="easyui-layout" data-options="fit:true">
    <div data-options="region:'center',border:true">
        <div id="datagridId"></div>

        <div id="datagridTb">
            <div class="row">
                <div class="col-md-12">
                    <form id="searchForm">
                        <div class="easyui-panel" title="信息查询" style="width:100%;padding:10px;"
                             data-options="iconCls:'icon-application_form'">

                            参数名称: <input class="easyui-textbox" id="configCName" data-options="validType:{length:[0,100]}" style="width:200px">&nbsp;&nbsp;


                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true" onclick="datagridQuery();" iconCls="icon-zoom">#(_res.get('system.common.search'))</a>
                            <a href="javascript:;" class="easyui-linkbutton" data-options="plain:true" onclick="$('#searchForm').form('clear');" iconCls="icon-zoom_out">#(_res.get('system.common.clear'))</a>
                        </div>
                    </form>
                </div>
                <div class="row">
                    <div class="col-md-12" style="padding: 5px 25px;">
                        #for(resource : resourceList)
                        <a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'#(resource.icon)',plain:true" id='#(resource.url)'>#(_res.get(resource.resourceName))</a>
                        #end
                    </div>
                </div>
            </div>
        </div>
    </div>




</div>

#end


#define css()

#end


#define js()

<script type="text/javascript">
    var _datagrid = "datagridId", _form = "formId", _datagridTb = "datagridTb";
    var datagridListUrl = contextRootPath + '/servicePlugin/list?pluginArgument.sp_id=#(servicePlugin.sp_id)';

    $(function () {

        //初始化表格
        $("#" + _datagrid).datagrid({
            url: datagridListUrl,
            fit: true,
            border: false,
            rownumbers: true,
            pageSize: 30,
            toolbar: '#' + _datagridTb,
            singleSelect: false,
            pagination: true,
            nowrap: false,
            striped: true,
            fitColumns: true,
            columns: [[
                {
                    field: DBConts.TABLE_PLUGIN_ARGUMENT.PA_ID,
                    title: DBConts.TABLE_PLUGIN_ARGUMENT.PA_ID,
                    checkbox: true
                },
                {
                    field: DBConts.TABLE_PLUGIN_ARGUMENT.CONFIG_CNAME,
                    title: '参数名称',
                    sortable: true
                },
                {
                    field: DBConts.TABLE_PLUGIN_ARGUMENT.CONFIG_VALUE,
                    title: '参数内容',
                    sortable: true
                },
                {
                    field: DBConts.TABLE_PLUGIN_ARGUMENT.DES,
                    title: '描述',
                    sortable: true
                },
                {
                    field: 'createts',
                    title: '创建时间',
                    sortable: true
                }
            ]]
        });



        #set(pluginArgumentAdd = 'plugin_argument_add'+pluginType)
        #set(pluginArgumentEdit = 'plugin_argument_edit'+pluginType)
        #set(pluginArgumentRemove = 'plugin_argument_remove'+pluginType)


         #for(resource : resourceList)

            #if(resource.url == pluginArgumentAdd)

            $("##(resource.url)").on('click', function () {
                var params = {};
                params.title = '#(_res.get(resource.resourceName))';
                params.width = 700;
                params.height = 280;
                params.top = '10px';
                params.modal = true;
                params.iconCls = 'icon-application_add';
                params.url = contextRootPath + '/servicePlugin/add?pluginArgument.sp_id=#(servicePlugin.sp_id)';
                params.buttons = [{
                    text: '提交',
                    iconCls: 'icon-application_go',
                    handler: function () {
                        datagrid_save('add');
                    }
                }];

                crud_dlg(params);
            });

        #elseif(resource.url == pluginArgumentEdit)

            $("##(resource.url)").on('click', function () {
                var selected = $('#' + _datagrid).datagrid('getSelected');


                if (selected == null) {
                    $.messager.alert("提示框", "请选择需要操作的参数!", "warning");
                    return;
                }

                var selections = $('#' + _datagrid).datagrid('getSelections');

                if (selections.length < 1) {
                    $.messager.alert("提示框", "请选择需要操作的参数!", "warning");
                    return;
                } else if (selections.length > 1) {
                    $.messager.alert("提示框", "编辑的参数为多个，请重新选择!", "warning");
                    return;
                }

                var params = {};
                params.title = '#(_res.get(resource.resourceName))';
                params.width = 700;
                params.height = 280;
                params.top = '10px';
                params.modal = true;
                params.iconCls = 'icon-application_edit';
                params.url = contextRootPath + '/servicePlugin/edit/' + selected[DBConts.TABLE_PLUGIN_ARGUMENT.PA_ID];
                params.buttons = [{
                    text: '提交',
                    iconCls: 'icon-application_go',
                    handler: function () {
                        datagrid_save();
                    }
                }, {
                    text: '关闭',
                    iconCls: 'icon-application_side_contract',
                    handler: function () {
                        $('#crud_dlg').dialog('close');
                    }
                }];

                crud_dlg(params);
            });

        #elseif(resource.url == pluginArgumentRemove)

            $("##(resource.url)").on('click', function () {
                var selections = $('#' + _datagrid).datagrid('getSelections');
                var ids = "";

                if (selections.length < 1) {
                    $.messager.alert("提示框", "请选择需要操作的参数!", "warning");
                    return;
                }

                $.messager.confirm('确认框', '请确定需要删除所选择的参数么？', function (r) {
                    if (r) {
                        $.each(selections, function (i, v) {
                            ids += v[DBConts.TABLE_PLUGIN_ARGUMENT.PA_ID] + ",";
                        });

                        $.post(contextRootPath + "/servicePlugin/remove?ids=" + ids + "&spId=#(servicePlugin.sp_id)", function (data) {
                            var params = {};
                            params.element = _datagrid;
                            params.data = data;
                            params.isClose = false;
                            resultCallback(params);
                        }, 'json');
                    }
                });


            });
        #elseif(resource.url == 'authorization')

            $("##(resource.url)").on('click', function () {

                var params = {};
                params.title = '#(_res.get(resource.resourceName))';
                params.width = 700;
                params.height = 280;
                params.top = '10px';
                params.modal = true;
                params.iconCls = 'icon-page_white_gear';
                params.url = contextRootPath + '/servicePlugin/authorization';
                params.buttons = [{
                    text: '提交',
                    iconCls: 'icon-application_go',
                    handler: function () {
                        authorization_save();
                    }
                }, {
                    text: '关闭',
                    iconCls: 'icon-application_side_contract',
                    handler: function () {
                        $('#crud_dlg').dialog('close');
                    }
                }];

                crud_dlg(params);
            });
        #elseif(resource.url == 'cert_statistics')

            $("##(resource.url)").on('click', function () {

                var params = {};
                params.title = '#(_res.get(resource.resourceName))';
                params.width = 2000;
                params.height = 2000;
                params.top = '10px';
                params.modal = true;
                params.iconCls = 'icon-chart_bar';
                params.url = contextRootPath + '/servicePlugin/certStatistics';

                crud_dlg(params);
            });

        #elseif(resource.url == 'cert_use_detail')

        $("##(resource.url)").on('click', function () {

            var params = {};
            params.title = '#(_res.get(resource.resourceName))';
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-text_align_justify';
            params.url = contextRootPath + '/servicePlugin/certUseDetail';

            crud_dlg(params);
        });

        #elseif(resource.url == 'deviceid_prefix')

            $("##(resource.url)").on('click', function () {
                var  displayName= encodeURI(encodeURI("设备ID前缀"));
                var params = {};
                params.dlgId="dict_ext_dlg_id",
                params.title = '#(_res.get(resource.resourceName))';
                params.width = 2000;
                params.height = 2000;
                params.top = '10px';
                params.modal = true;
                params.iconCls = 'icon-shape_rotate_clockwise';
                params.url = contextRootPath + '/dict/dict?isDisplay=0&displayName='+displayName+'&dtId=#(com.gmrz.uap.dict.DictConst::DICT_TYPE_DEVICEID_PREFIX_ID)';

                crud_dlg(params);
            });
        #elseif(resource.url == 'upload_file_form')

        $("##(resource.url)").on('click', function () {

            var params = {};
            params.title = '#(_res.get(resource.resourceName))';
            params.width = 2000;
            params.height = 2000;
            params.top = '10px';
            params.modal = true;
            params.iconCls = 'icon-chart_bar';
            params.url = contextRootPath + '/servicePlugin/uploadFileForm';
            params.buttons = [{
                text: '提交',
                iconCls: 'icon-application_go',
                handler: function () {
                    datagrid_save('add');
                }
            }, {
                text: '重置',
                iconCls: 'icon-application_side_contract',
                handler: function () {
                    clearForm('formId')
                }
            }];

            crud_dlg(params);
        });

        #end
      #end

    });


    function datagridQuery() {
        var flag = $("#searchForm").form('enableValidation').form('validate');

        if (!flag) return;

        $("#" + _datagrid).datagrid({
            queryParams: {
                "pluginArgument.config_cname": $("#configCName").val()
            }
        });
    }
</script>

#end



